package com.sxt.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sxt.sys.domain.Room;
import com.sxt.sys.service.RoomService;
import com.sxt.sys.utils.DataGridView;
import com.sxt.sys.utils.ResultObj;
import com.sxt.sys.vo.RoomVo;
import com.sxt.sys.vo.RoomVo;

@RestController
@RequestMapping("room")
public class RoomController {
	
	@Autowired
	private RoomService roomService;
	
    
	//加载客房查询
			@RequestMapping("loadAllRoom")
			public DataGridView loadAllRoom(RoomVo roomVo) {
				return roomService.queryAllRoom(roomVo);
				}
			
		
			@RequestMapping("loadRoom")
			public  List<Room> loadRoom(RoomVo roomVo) {
				
				return roomService.queryAllRoomForList(roomVo);
			}
		
	
	//添加客房
		@RequestMapping("addRoom")
		public ResultObj addRoom(RoomVo roomVo) {
			try {
				roomService.addNewRoom(roomVo);
				return new ResultObj(200, "添加成功");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return new ResultObj(-1, "添加失败");
		}
	
		//删除客房
		@RequestMapping("deleteRoom")
		public ResultObj deleteRoom(Integer id) {
			try {
				roomService.deleteRoom(id);
				return new ResultObj(200, "删除成功");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return new ResultObj(-1, "删除失败");
		}
		
}
